<template>
  <div class="applyList">
    <div class="searchBox">
      <el-form :inline="true" :model="formInline">
        <el-form-item label="检测时间">
          <el-date-picker
            size="small"
            v-model="formInline.date"
            type="datetimerange"
            value-format="yyyy-MM-dd HH:mm:ss"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="small" @click="handleSearch">搜索</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>查询列表</span>
        <div class="btnBox">
          <el-button type="primary" size="small" @click="$router.push('/apply/addApply')">新增</el-button>
        </div>
      </div>
      <div>
        <el-table
          header-cell-class-name="header-class"
          :data="tableData"
          border>
          <el-table-column
            prop="detectionTime"
            label="检测时间"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="notificationName"
            label="通知名称"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="detectionNumber"
            show-overflow-tooltip
            label="检测总人数">
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作"
            width="100">
            <template slot-scope="{row}">
              <el-button type="text" size="small" @click="handleView(row)">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
        <Pagination :total="page_total" @pageChange="pageChange" :page="page"></Pagination>
      </div>
    </el-card>


  </div>
</template>

<script>
  export default {
    name: "applyList",
    data() {
      return {
        formInline: {
          date: []
        },
        tableData: [],
        page: {
          page_index: 1,
          page_limit: 10
        },
        page_total: 0, //总条数
      }
    },
    methods: {
      pageChange(item) {
        this.page.page_index = item.page_index;
        this.page.page_limit = item.page_limit;
        this.init()//改变页码，重新渲染页面
      },
      handleSearch() {
        this.page.page_index = 1
        this.init()
      },
      init() {
        let params = {
          pageNo: this.page.page_index,
          pageSize: this.page.page_limit,
          startDate: this.formInline.date && this.formInline.date.length > 0 ? this.formInline.date[0] : '',
          endDate: this.formInline.date && this.formInline.date.length > 0 ? this.formInline.date[1] : '',
        }
        this.$ajax.peng.queryNucleinDetectionApplyRecord(params).then(data => {
          this.tableData = data.data.list
          this.page_total = data.data.total
        })
      },
      handleView(row) {
        this.$router.push({
          path: '/apply/addApply',
          query: {
            id: row.id
          }
        })
      }
    },
    mounted() {
      this.init()

    },
  }
</script>

<style>
  .applyList .el-card__header {
    padding: 13px 20px;
    line-height: 30px;
  }
</style>
